Skip to content

Fix problem with docker internal networks #350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

anlorn
Copy link
Contributor

@anlorn anlorn commented Apr 30, 2021

Hello, I found an issue while setting up nginx-proxy container for my network.

I have the following setup:

  1. network 'A' is a regular network created in docker
  2. network 'B' is an internal network created with --internal parameter

Container with nginx-proxy connected to both A and B networks. At the same time, containers with applications are connected only to 'B' network. When running such a config, I was always getting.

After investigating, I find out that the issue comes from the fact that 'docker inspect' section NetworkSettings.Ports is always empty for internal networks, no matter which port you expose/publish. As the result we always have empty addresses variable when we generate a template. Solution here is to take exposed ports from section Config.ExposedPorts when NetworkSettings.Ports is empty.

How to reproduce:
Create internal network docker network create 'test_network' --internal
Run httpd container connected on this network docker run --network test_network --rm -e VIRTUAL_HOST=test.local -e VIRTUAL_PORT=80 httpd:2.4-alpine
Get latest nginx.tml wget https://github.com/raw/nginx-proxy/nginx-proxy/main/nginx.tmpl
Run docker run --network test_network -it --rm -v /run/docker.sock:/tmp/docker.sock -v $(pwd):/app/ jwilder/docker-gen /app/nginx.tmpl
You will see that in the upstream section of the generated config server directive is marked as down.
Repeat all the steps but this time, on step 1, create a network without the --internal parameter.

Docker internak networks have empty map in `NetworkSettings.Ports`.
So, docker-gen was returning empty `runtimeContainer.Addresses` for
containers on internal networks
@buchdag
Copy link
Member

buchdag commented Dec 19, 2023

Superseded by #579

@buchdag buchdag closed this Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants